package tributos.dao;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

import tributos.interfaces.ImoveisDao;
import tributos.modelo.Imoveis;
import tributos.util.HibernateUtil;

public class ImoveisDaoImpl implements ImoveisDao{

	@Override
	public void salvarImoveis(Imoveis imoveis) {
		Session session = HibernateUtil.getSession();
		Transaction t = session.beginTransaction();
		session.save(imoveis);
		t.commit();	
		session.close();
		
	}
	
	
	@Override
	public Number totalRegistros() {
		Session session = HibernateUtil.getSession();
		Query query = session.createSQLQuery("select MAX(id) from imoveis");
		Number numero = (Number) query.uniqueResult();
		session.close();
		return numero;
	}

}
